﻿using System.Collections.Generic;

namespace Autoupdate.Common
{
    // 版本表
    public class SysUpdateVersion
    {
        // 表名
        public const string TableName = "Sys_UpdateVersion";

        public const string Id = "VersionId";
        public const string Module = "ModuleName";
        public const string Name = "VersionName";
        public const string Description = "VersionDescription";
        public const string Time = "UpdateTime";
        public const string Locked = "Locked";
    }

    // 文件表
    public class SysUpdateFile
    {
        // 表名
        public const string TableName = "Sys_UpdateFile";

        public const string Index = "FileIndex";
        public const string Name = "FileName";
        public const string Path = "FilePath";
        public const string MD5 = "FileMD5";
        public const string Data = "FileData";
        public const string Usage = "FileUsage";

        public const string Status = "FileStatus";
    }

    public class FileUsage
    {
        public const string Run = "Run";
        public const string Icon = "Icon";
        public const string PreUpdate = "PreUpdate";
        public const string PostUpdate = "PostUpdate";
        public const string Ignore = "Ignore";
    }

    public static class IgnoreFiles
    {
        private static List<string> ignoreFiles = new List<string>();

        public static bool Contains(string file)
        {
            if (ignoreFiles.Count == 0)
            {
                ignoreFiles.AddRange(new string[]
                {
                    "Autoupdate.exe",
                    "Autoupdate.pdb",
                    "Autoupdate.vshost.exe",
                    "Autoupdate.vshost.exe.manifest",
                    "AutoupdateCommon.dll",
                    "AutoupdateCommon.pdb",
                    @"Data\Log.txt",
                    //@"Update\Autoupdate.cfg",
                    @"Update\Log.txt",
                    @"Update\DBSetting.xml"
                });
            }
            return ignoreFiles.Contains(file);
        }
    }
}
